package org.finesys.message.controller;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.finesys.message.producer.MqProducer;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequiredArgsConstructor
@RequestMapping("/mq")
@Slf4j
public class MqMessageController {

    private final MqProducer mqProducer;

    @Value("${channel-name-out}")
    private String bindingName;

    @PostMapping("/sendMessage")
    public void sendMessage(@RequestBody Map<String, Object> message) {
        log.info("Sending message: {}", message);
        System.out.println("Sending message: " + message);
        mqProducer.send(bindingName, message);
    }

    @GetMapping("/sendMessageMq")
    public void sendMessage(String message) {
        log.info("Sending get message: {}", message);
        System.out.println("Sending message: " + message);
        mqProducer.send(bindingName, message);
    }
}
